<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div>
        <h1 id="content">debounce</h1>
        <button id="buttonContent" onclick="debounceBtn()">debounce</button>
    </div>
</body>
<script src="./debounce.js"></script>
<script>
    let num = 1;
    let content = document.getElementById('content');
    let buttonContent = document.getElementById('buttonContent');

    function count() {
        content.innerHTML = num++;
    };
    // 立即执行
    // content.onmousemove = count;
    // 短时间内只执行最后一次或第一次，中间不执行
    content.onmousemove = debounce(count, 1000);

    var debounceBtn = (function() {
            return debounce(count, 1000)
        })()
        // buttonContent.onclick = debounce(count,1000);
</script>

</html>